"""
自制一个密码生成器
"""
import random


################################################# >>>指定密码的字母、数字和符号的范围<<< #################################################
letters = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k",
           "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v",
           "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G",
           "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R",
           "S", "T", "U", "V", "W", "X", "Y", "Z"] # 随机字母范围
numbers = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] # 随机数字范围
symbols = ["!", "#", "$", "%", "&", "(", ")", "*", "+"] # 随机符号范围

################################################# >>>用输入指定密码的字母、数字和符号的个数<<< #################################################
num_letters = int(input("请指定密码中包含字母的个数：")) # 指定密码中包含字母的个数
num_numbers = int(input("请指定密码中包含数字的个数：")) # 指定密码中包含数字的个数
num_symbols = int(input("请指定密码中包含符号的个数：")) # 指定密码中包含符号的个数

################################################# >>>生成密码的字母、数字和符号的随机<<< #################################################
temp_password = []

for i in range(num_letters): # 随机根据用户输入的数字进行密码筛选
    ran_letters = random.choice(letters) # 随机选择字母
    temp_password.append(ran_letters) # 将随机选择的字母添加到列表中

for i in range(num_numbers): # 随机根据用户输入的数字进行密码筛选
    ran_numbers = random.choice(numbers) # 随机选择数字
    temp_password.append(ran_numbers) # 将随机选择的数字添加到列表中

for i in range(num_symbols): # 随机根据用户输入的数字进行密码筛选
    ran_symbols = random.choice(symbols) # 随机选择符号
    temp_password.append(ran_symbols) # 将随机选择的符号添加到列表中

random.shuffle(temp_password) # 将列表中的元素随机排序

# final_password = "".join(temp_password) # 将列表中的元素拼接成字符串
final_password = "" # 初始化一个空字符串
for i in temp_password: # 遍历列表中的元素
    final_password += i # 将列表中的元素添加到字符串中


print(final_password) # 打印密码



